﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Wassrile.Config.ConfigPage
{
    public partial class PostBehavior : Krilib.Control.ConfigPage
    {
        public PostBehavior()
        {
            InitializeComponent();
        }

        private string[] myList = null;

        private void EditCustomPallet_Click(object sender, EventArgs e)
        {
            using (var mlf = new Dialogs.CustomPalletEditor())
            {
                mlf.PictogramList = myList;
                mlf.ShowDialog();
                myList = mlf.PictogramList;
            }
        }

        private void PostBehavior_Load(object sender, EventArgs e)
        {
            Signature.Text = Core.Config.Post.Signature;
            refreshAfterPost.Checked = Core.Config.Post.refreshAfterPost;
            alwaysReplyUseAt.Checked = Core.Config.Post.alwaysReplyUseAt;
            autoFav.Checked = Core.Config.Post.replyToFav;
            noReplyInChPost.Checked = Core.Config.Post.dontReplyBehaviorInChannel;
            lostFocusToClose.Checked = Core.Config.Behavior.PictPallet.closeOnLostFocus;
            saveSize.Checked = Core.Config.Behavior.PictPallet.saveSize;
            savePosition.Checked = Core.Config.Behavior.PictPallet.saveLocation;
            if (Core.Config.Behavior.PictPallet.customPalletItems != null)
            {
                myList = new string[Core.Config.Behavior.PictPallet.customPalletItems.Length];
                Core.Config.Behavior.PictPallet.customPalletItems.CopyTo(myList, 0);
            }
        }

        public override void Apply()
        {
            Core.Config.Post.useSignature = useSignature.Checked;
            Core.Config.Post.Signature = Signature.Text;
            Core.Config.Post.refreshAfterPost = refreshAfterPost.Checked;
            Core.Config.Post.alwaysReplyUseAt = alwaysReplyUseAt.Checked;
            Core.Config.Post.replyToFav = autoFav.Checked;
            Core.Config.Post.dontReplyBehaviorInChannel = noReplyInChPost.Checked;
            Core.Config.Behavior.PictPallet.closeOnLostFocus = lostFocusToClose.Checked;
            Core.Config.Behavior.PictPallet.saveSize = saveSize.Checked;
            Core.Config.Behavior.PictPallet.saveLocation = savePosition.Checked;
            Core.Config.Behavior.PictPallet.customPalletItems = myList;
        }
    }
}
